package ch.usi.inf.pf2;
import junit.framework.TestCase;


/**
 * @author Ebrisa Savina Mastrodicasa
 * @date April 17th, 2010
 */


public class TestSheet extends TestCase {

	private Sheet sheet1;
	private Sheet sheet2;
	
	
	/**
	 * Set up properly some standard variable for the tests.
	 */
    protected void setUp()
    {
		sheet1 = new Sheet();
		sheet2 = new Sheet(10, 35, "first-sheet");
	}
    
    
    /**
     * Check that the getRows() method returns the real
     * number of rows called on a default sheet.
     */
    public void testGetRowsInDefaultSheet()
    {
    	assertEquals(100, sheet1.getRows());
    }
    
    
    /**
     * Check that the getColumns() method returns the real
     * number of columns called on a default sheet.
     */
    public void testGetColumnsInDefaultSheet()
    {
    	assertEquals(100, sheet1.getColumns());
    }
    
    
    /**
     * Check that the getRows() method returns the real
     * number of rows called on some sheet.
     */
    public void testGetRowsInSomeSheet()
    {
    	assertEquals(35, sheet2.getRows());
    }
    
    
    /**
     * Check that the getColumns() method returns the real
     * number of columns called on some sheet.
     */
    public void testGetColumnsInSomeSheet()
    {
    	assertEquals(10, sheet2.getColumns());
    }
    
    
    /**
     * Check that the getName() method returns the real
     * name called on a default sheet.
     */
    public void testGetNameInDefaultSheet()
    {
    	assertEquals(null, sheet1.getName());
    }
    
    
    /**
     * Check that the getName() method returns the real
     * name on some sheet.
     */
    public void testGetNameInSomeSheet()
    {
    	assertEquals("first-sheet", sheet2.getName());
    }
    
    /**
     * Check that the getCell() method returns the right Cell
     */
    public void testGetCell() 
    {
    	sheet1.insertDataAtCell("ciao", 1, 3);
    	assertEquals("ciao", sheet1.getCell(1, 3).getContent().toString());
    }
    
    
    /**
     * Check that getCellByName() method returns the content
     * of the wanted cell.
     */
    public void testGetCellByName() 
    {
    	sheet1.insertDataAtCell("hi", "A4");
    	assertEquals("hi", sheet1.getCellByName("A4").toString());
    }
    
    
    
    
    
}
